
#include "helper_tmpl.h"

#ifndef PURG_C_INTERFACE_COMPILE
namespace purg
{
#endif

  template <unsigned char BYTE , unsigned int BUFFER_LENGTH>
  void  single_byte_stream_tmpl<BYTE,BUFFER_LENGTH>::initialize ( state & , buffer &b , seed & , size_t )
  {
    for ( unsigned int i = 0 ; i != BUFFER_LENGTH ; i++ )
      b[i] = BYTE;
  }


  template <unsigned char BYTE , unsigned int BUFFER_LENGTH>
  void  single_byte_stream_tmpl<BYTE,BUFFER_LENGTH>::update_buffer ( state & , buffer & )
  {
  }


  template <unsigned int MULTIPLIER , 
            unsigned int INCREMENT , 
            unsigned int MODULUS>
  void lcg_pow_2_tmpl<MULTIPLIER , INCREMENT , MODULUS>
               ::perform_update ( state &in , state &out )
  {
    out = (MULTIPLIER * in + INCREMENT);
//    if ( MODULUS < 32 )
//      out %= pow<2,MODULUS>::result;
  }


  template <unsigned int MULTIPLIER , 
            unsigned int INCREMENT , 
            unsigned int MODULUS>
  void lcg_pow_2_tmpl<MULTIPLIER , INCREMENT , MODULUS>
               ::initialize ( state &s , buffer &b , seed &see , size_t pid )
  {
    s = see;
    update_buffer ( s , b );
  }

  template <unsigned int MULTIPLIER , 
            unsigned int INCREMENT , 
            unsigned int MODULUS>
  void lcg_pow_2_tmpl<MULTIPLIER , INCREMENT , MODULUS>
               ::update_buffer ( state &s , buffer &b )
  {
    unsigned int *buf = reinterpret_cast<unsigned int*> ( &(b[0]) );
    perform_update ( s , *buf );
    s = *buf;
  }
#ifndef PURG_C_INTERFACE_COMPILE
}
#endif
